<template>
  <div class="fl">
    <div class="fl-top">
      <div>
        <img
          src="../image/saoma_icon_fanhui.png"
          alt=""
          @click="$router.push({ name: 'index' })"
        />
      </div>
      <h2>试用中心</h2>
      <p>我参与的</p>
    </div>
    <van-tabs v-model="activeName" @change="onPrevious">
      <van-tab title="当前测试" name="a" @click="flag = 2">
        <div
          class="current"
          v-for="(item, index) in CommodityList"
          :key="index"
        >
          <div class="current-top">
            <img :src="item.img" alt="" />
            <p>{{ item.name }}</p>
            <button>免费申请</button>
          </div>
          <p>距离结束1天22小时01分26秒</p>
        </div>
      </van-tab>
      <van-tab title="即将上线" name="b">
        <div class="soon">
          <img src="../image/zhuangpintiixng_icon_photo.png" alt="" />
          <p>敬请期待</p>
        </div>
      </van-tab>
      <van-tab title="往期试用" name="c">
        <div
          class="current"
          v-for="(item, index) in CommodityList"
          :key="index"
        >
          <div class="current-top">
            <img :src="item.img" alt="" />
            <p>{{ item.name }}</p>
          </div>
        </div>
      </van-tab>
    </van-tabs>
  </div>
</template>

<script>
import { Flagapi } from "../../../services/IndexApi";
export default {
    data() {
        return {
        activeName: "a",
        CommodityList: [],
        flag: 3,
        };
    },
    created() {
        Flagapi(this.flag).then((res) => {
        //   console.log(res.data);
        this.CommodityList = res.data;
        });
    },
    methods: {
        onPrevious(name) {
          console.log(name);
            if(name === "c"){
                Flagapi(1).then(res=>{
                this.CommodityList=res.data;
            })
            }else if(name === "a"){
                Flagapi(3).then((res) => {
                this.CommodityList = res.data;
                });
            }
        },
    },
    };
</script>

<style lang="scss" scoped>
* {
  margin: 0;
  padding: 0;
}
.fl-top {
  margin-top: 105px;
  display: flex;
  justify-content: space-between;
}
.fl-top div {
  width: 96px;
}
.fl-top img {
  width: 12px;
  height: 24px;
  margin-top: 12px;
  margin-left: 43px;
}
.fl-top h2 {
  width: 206px;
  height: 48px;
  font-size: 34px;
  font-family: PingFangSC-Medium-, PingFangSC-Medium;
  /* font-weight: normal; */
  color: #2f2f2f;
  line-height: 48px;
  text-align: center;
  /* background: red; */
}
.fl-top p {
  width: 96px;
  height: 48px;
  font-size: 24px;
  font-family: PingFang SC-Regular, PingFang SC;
  font-weight: 400;
  color: #2f2f2f;
  line-height: 48px;
  margin-right: 20px;
  /* background: blue; */
}
.fl {
  width: 100vw;
  height: 100vh;
  border: 1px solid #fff;
  .van-tabs {
    margin-top: 25px;
    .van-tabs__nav{
      // margin-left: -140px;
    }
  }
  .van-tab {
    width: 200px;
    height: 80px;
    span {
      height: 80px;
      font-size: 28px;
      line-height: 45px;
      width: 200px;
    }

  }
  .van-tab__pane {
    // text-align: center;
    // 当前
    .current {
      margin-top: 57px;
      width: 656px;
      height: 302px;
      opacity: 1;
      // border: 1px solid red;
      margin-left: 55px;
      margin-bottom: 74px;
      .current-top {
        display: flex;
        img {
          width: 236px;
          height: 236px;
        }
        p {
          width: 288px;
          height: 117px;
          font-size: 24px;
          font-family: PingFang SC-Regular, PingFang SC;
          font-weight: 400;
          color: #2f2f2f;
          line-height: 42px;
          margin-top: 61px;
        }
        button {
          width: 154px;
          height: 58px;
          background: #bbd2f4;
          border-radius: 28px 28px 28px 28px;
          opacity: 1;
          border: none;
          margin-top: 178px;
          font-size: 24px;
          font-family: PingFang SC-Regular, PingFang SC;
          font-weight: 400;
          color: #ffffff;
        }
      }
      p {
        width: 378px;
        height: 40px;
        font-size: 28px;
        font-family: PingFang SC-Regular, PingFang SC;
        font-weight: 400;
        color: #2f2f2f;
        line-height: 13px;
        margin-top: 26px;
        // margin-left: 30px;
      }
    }
    // 即将
    .soon {
      text-align: center;
      img {
        width: 510px;
        height: 510px;
        margin-top: 135px;
      }
      p {
        // width: 96px;
        // height: 33px;
        font-size: 24px;
        font-family: PingFang SC-Regular, PingFang SC;
        font-weight: 400;
        color: #2f2f2f;
        // line-height: 13px;
      }
    }
  }
}
</style>